Repository navigation
fix!: pass variadic inputs in connection order in Pipeline.run() and run_async() - #13415
Merged
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||
julian-risch
removed their request for review
November 4, 2026 11:51
sjrl
reviewed
Nov 6, 2026
sjrl
reviewed
Nov 6, 2026
sjrl
reviewed
Nov 6, 2026
sjrl
reviewed
Nov 6, 2026
Contributor
|
Now that the order is defined, lets document it in the |
…r, add upgrade note
Contributor
|
Since we now have an |
sjrl
approved these changes
Nov 9, 2026
sjrl
left a comment
Contributor
There was a problem hiding this comment.
Looks good! One minor comment about updating the PR title
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issues
Proposed Changes:
The problem
A component with a lazy variadic input (
DocumentJoiner.documents,AnswerJoiner.answers, anyVariadic[...]or multi-senderlist[...]input) received its values in arrival order:run(), that's the execution order. It's deterministic, but hard to predict: it depends on depth, deferral of components with optional inputs, and tie-breaks.run_async(), it's completion order, so it depends on timing.So
run_async()could give different results between runs, platforms and Python versions, and different results fromrun(). For example,DocumentJoiner(join_mode="merge", weights=[0.7, 0.3])could apply the weights to the wrong retrievers.The fix
Instead of depending on when each sender runs or finishes, the order now comes from the pipeline definition: a lazy variadic input receives its values in the order its senders were connected with
Pipeline.connect(). Each input socket already records its senders in that order, so the pipeline sorts the values by it just before the component reads them.The same rule applies in
run(),run_async()andrun_async_generator(), so the order is the same in every run and in both modes. Users control it through theirconnect()calls:weights[i]of aDocumentJoinerapplies to the i-th connection.GreedyVariadic(BranchJoiner) is unchanged, since it takes the first value that arrives.Other options explored (all async only, trying to match
run()'s order)run(), where deeper senders run later whatever their name. It fails the hybrid retrieval test.run()'s deferral of components with unfilled optional inputs, and swaps the joiner weights when an optional filter branch doesn't fire.run()'s scheduler during the async run. Exact, but it means a second scheduler of a few hundred lines to keep in sync withrun(), and joiners can start later.run()'s execution order is hard to reproduce and hard for users to predict, so this PR uses connection order instead.Code changes (
haystack/core/pipeline/base.py)_consume_component_inputs()sorts each lazy variadic socket's entries with_sort_by_connection_order()before flattening them. Both run modes go through this function._connection_index()gives each entry's sort key:-1for user inputs;socket.senders, whichconnect()already maintains;len(socket.senders)for unlisted senders, which go last.The sort is stable.
to_dict()lists the connections into each socket in connection order.graph.edgeslists them grouped by sender, which lost that order on a round trip. Sockets with a single sender are unaffected.How did you test it?
New tests, all of them asserting the same result for
run()andrun_async():test_run_async_passes_variadic_inputs_in_same_order_as_run: a customVariadic[str]collector, where the sender connected first finishes last in async.test_run_async_applies_document_joiner_weights_to_the_retrievers_in_connection_order: hybrid retrieval with weights, in both connection orders. In each order, one run mode finishes the retrievers in the other order. The expected output isDocumentJoiner.run()called directly on the retriever outputs, in connection order.test_run_async_applies_document_joiner_weights_like_run_when_an_optional_filter_branch_is_skipped: the optional filter case where Option 2 failed.test_run_async_passes_variadic_inputs_in_connection_order_on_every_loop_iteration: connection order holds in every round of a loop, where neither mode's natural order matches it.test_to_dict_from_dict_round_trip_keeps_variadic_connection_order: senders connected in the opposite order toadd_component().test__consume_component_inputscase: interleaved values from the same sender keep their own order.Updated tests:
test/core/pipeline/features/test_run.py: allAnyOrderrelaxations from chore!: drop Python 3.10 support, add Python 3.15 #13054 and feat: Updates to make Haystack compatible with python 3.14 #10634 are reverted to exact lists. 4 scenarios are rewritten to the connection-order result.test_pipeline.pyandtest_pipeline_base.pyare updated to connection order.Notes for the reviewer
to_dict()output changes order for multi-sender sockets only.run()behaviour changes for pipelines where execution order differs from connection order. For example, which retriever gets which joiner weight, or which copy of a duplicateDocumentJoinerkeeps inconcatenatemode. The release note is underfixesand tells users to connect senders in the order they want. Should this befix!:with anupgradenote instead?